// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_FIN_MAP_RECEIVED_DELIVERY
// * CreateDate    : 2012/4/10 09:41:25
// * Creater       : CodeSmith
// * LastChangeDate: 2012/4/10 09:41:25
// * LastChanger   : 2012/4/10 09:41:25
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Fin
{
/// <summary>
    /// FinMapReceivedDelivery
    /// </summary>
    public partial class FinMapReceivedDeliveryBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objFinMapReceivedDeliveryEntity">Entity</param>
        /// <returns>Entity</returns>
        public static FinMapReceivedDeliveryEntity GetFinMapReceivedDelivery(FinMapReceivedDeliveryEntity objFinMapReceivedDeliveryEntity)
        {
            return DataAccess.SelectSingle<FinMapReceivedDeliveryEntity>(objFinMapReceivedDeliveryEntity);
        }
        public static DataTable GetDeliveryItemsByDetailId(string detailId)
        {
            if (detailId == null)
            {
                return null;
            }
            string sql = @"SELECT ITEM.*, MAP.*, P.PRODUCT_CODE,P.PRODUCT_SPEC_OUT, P.PRODUCT_SPEC_IN, P.PRODUCT_NAME, O.DELIVERY_ORDER_CODE,O.DELIVERY_DATE, MP.NAME_CN AS ORDER_PERSON_NAME, CONVERT(DECIMAL(18,2),ITEM.QTY * ITEM.PRICE) AS ITEM_AMOUNT
                            FROM SALES_DELIVERY_ITEM ITEM
                            INNER JOIN SALES_DELIVERY_ORDER O ON O.DELIVERY_ORDER_ID = ITEM.DELIVERY_ORDER_ID
                            INNER JOIN FIN_MAP_RECEIVED_DELIVERY MAP ON MAP.DELIVERY_ITEM_ID = ITEM.DELIVERY_ITEM_ID
                            LEFT JOIN MST_PRODUCT P ON P.PRODUCT_ID = ITEM.PRODUCT_ID
							LEFT JOIN MST_PERSON MP ON MP.PERSON_ID = O.DELIVERY_PERSON
                            WHERE MAP.RECEIVED_DETAIL_ID = '" + detailId + "'";
            return DataAccess.SelectDataSet(sql).Tables[0];
        }
        #endregion

        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objFinMapReceivedDeliveryEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertFinMapReceivedDelivery(FinMapReceivedDeliveryEntity objFinMapReceivedDeliveryEntity)
        {
            return DataAccess.Insert(objFinMapReceivedDeliveryEntity);
        }

        public static bool InsertFinMapReceivedDelivery(List<FinMapReceivedDeliveryEntity> objFinMapReceivedDeliveryEntityList)
        {
            return DataAccess.Insert(objFinMapReceivedDeliveryEntityList);
        }
        #endregion

        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objFinMapReceivedDeliveryEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateFinMapReceivedDelivery(FinMapReceivedDeliveryEntity objFinMapReceivedDeliveryEntity)
        {
            return DataAccess.Update(objFinMapReceivedDeliveryEntity);
        }

        public static bool UpdateFinMapReceivedDelivery(List<FinMapReceivedDeliveryEntity> objFinMapReceivedDeliveryEntityList)
        {
            return DataAccess.Update<FinMapReceivedDeliveryEntity>(objFinMapReceivedDeliveryEntityList);
        }
        #endregion

        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objFinMapReceivedDeliveryEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteFinMapReceivedDelivery(FinMapReceivedDeliveryEntity objFinMapReceivedDeliveryEntity)
        {
            return DataAccess.Delete(objFinMapReceivedDeliveryEntity);
        }

        public static bool DeleteFinMapReceivedDelivery(List<FinMapReceivedDeliveryEntity> objFinMapReceivedDeliveryEntityList)
        {
            return DataAccess.Delete<FinMapReceivedDeliveryEntity>(objFinMapReceivedDeliveryEntityList);
        }
        #endregion

        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetFinMapReceivedDeliveryAll()
        {
            return DataAccess.SelectAllDataSet<FinMapReceivedDeliveryEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<FinMapReceivedDeliveryEntity> GetFinMapReceivedDeliveryAllList()
        {
            return DataAccess.SelectAll<FinMapReceivedDeliveryEntity>();
        }
        #endregion
	}
	
	
}	

